/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.so.trening;

import domen.OpstiDomenskiObjekat;
import domen.Trening;
//import java.sql.SQLException;
import java.util.LinkedList;
//import java.util.logging.Level;
//import java.util.logging.Logger;
import server.baza.DataBaseBroker;
import server.so.OpstaSO;

/**
 *
 * @author Ivan Ivic
 */
public class VratiSveTreninge extends OpstaSO {
    private LinkedList<Trening> listaTreninga;

    public LinkedList<Trening> vratiTreninge() {
        return listaTreninga;
    }
    
    public synchronized static LinkedList<Trening> vratiSveTreninge()
    {
        VratiSveTreninge vst = new VratiSveTreninge();
        Trening t = new Trening();
        vst.opsteIzvrsenjeSO(t);  // 9023, 9024
        return vst.vratiTreninge();
    }

    @Override
    public int izvrsenjeSO(OpstiDomenskiObjekat odo) {
        Trening t = (Trening) odo;
        listaTreninga = new LinkedList<Trening>();
        LinkedList<OpstiDomenskiObjekat> l = DataBaseBroker.getDbb().vratiSve(t);
        for (int i = 0; i < l.size(); i++) {
            listaTreninga.add((Trening) l.get(i));
        }
        //return 9023;
        return DataBaseBroker.getDbb().getSignal();

    }

    @Override
    public boolean stanjeOperacije(int signal) {
        switch(signal)
        {
            case 9023:
                prikazi(signal, "Svi slogovi vraceni");
                return true;
            case 9024:
                prikazi(signal, "Neuspesno vraceni svi slogovi");
                return false;
            default:
                return false;
        }
    }

}
